using System;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.Grid;
using E4RPDevExpress;
using ReferenciasSibs.DataSet;

namespace ReferenciasSibs.Controls
{
    public partial class ErrorsFileXtraUserControl : XtraUserControl, IGridView
    {
        public ErrorsFileXtraUserControl()
        {
            InitializeComponent();
        }

        public string FileName
        {
            set { fileTextEdit.Text = value; }
        }

        public ErroDataSet ImportData
        {
            set
            {
                originCalcEdit.Value = value.Header.Count == 1 ? value.Header[0].IdInstituicaoOrigem : 0;
                destinyCalcEdit.Value = value.Header.Count == 1 ? value.Header[0].IdInstituicaoDestino : 0;
                entityCalcEdit.Value = value.Header.Count == 1 ? value.Header[0].Entidade : 0;
                processingDateEdit.DateTime = value.Header.Count == 1 ? value.Header[0].DataProcessamento : DateTime.MinValue;
                originalProcessingDateEdit.DateTime = value.Header.Count == 1 ? value.Header[0].DataProcessamentoOriginal : DateTime.MinValue;
                erroDataSet.Clear();
                erroDataSet.Merge(value);
            }
        }

        public GridView GridView()
        {
            return gridView;
        }

        public string ListName
        {
            get { return "ErrorsFileXtraUserControl"; }
        }
    }
}
